{	Problem: http://codeforces.ru/problemset/problem/101/A
	Verdict: Accepted
}
uses
        SysUtils, Math;

type
        letter = record
                ch:char;
                v:longint;
        end;

var
        i,k,ls,cc,bb:longint;
        s:string;
        a:array[0..30] of letter;
        b:array[char] of boolean;

procedure sort(l,r:longint);

var
        i,j,x:longint;
        y:letter;

begin
i:=l;
j:=r;
x:=a[(l+r) shr 1].v;
repeat
        while a[i].v < x do inc(i);
        while a[j].v > x do dec(j);
        if i<=j then begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(I);
                dec(j);
        end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;

begin 
fillchar(b,sizeof(b),true);
readln(S);
read(k);
ls:=length(S);
for i:=1 to 26 do
        a[i].ch := chr (i + 96);
for i:=1 to ls do
        inc(a[ord(s[i]) - 96].v);
cc:=0;
for i:=1 to 26 do
        if a[i].v > 0 then inc(cc);
sort(1,26);
i:=1;
bb:=0;
while (i < 27) and (k >= a[i].v) do begin
        if a[i].v > 0 then begin
                inc(bb);
                b[a[i].ch]:=false;
        end;
        dec(k,a[i].v);
        inc(i);
end;
writeln(cc - bb);
for i:=1 to ls do
        if b[s[i]] then write(s[i]);
end.